<?php
$type = _POST('type', 'guess');
$limit = _POST('limit', 6);
switch ($type)
{
	case 'rand':
		$limit = 16;
		$sql = 'SELECT goods_id,goods_name name,goods_thumb,goods_img,original_img,market_price,shop_price FROM '.$ecs->table('goods').' WHERE is_real=1 AND is_on_sale=1 AND is_alone_sale=1 AND is_delete=0 AND promote_price=0 AND is_promote=0 AND goods_number>0 AND goods_thumb<>\'\' ORDER BY rand(),add_time DESC LIMIT '.$limit;
		break;
	case 'guess':
	default:
		$sql = 'SELECT goods_id,goods_name name,goods_thumb,goods_img,original_img,market_price,shop_price FROM '.$ecs->table('goods').' WHERE is_real=1 AND is_on_sale=1 AND is_alone_sale=1 AND is_delete=0 AND promote_price=0 AND is_promote=0 AND goods_number>0 AND goods_thumb<>\'\' ORDER BY is_hot DESC,is_new DESC,add_time DESC LIMIT '.$limit;
		break;
}
$data = $db->getAll($sql);

if ($data)
{
    foreach ($data as $k => $row)
    {
        $data[$k]['market_price'] = price_format($row['market_price']);
        $data[$k]['shop_price']   = price_format($row['shop_price']);
        $data[$k]['img']  = [
            'thumb' => API_DATA('PHOTO', $row['goods_thumb']),
            'url'   => API_DATA('PHOTO', $row['original_img']),
            'small' => API_DATA('PHOTO', $row['goods_img'])
        ];
    }
}
return $data?:[];